Skip to content

feat(testimonials): add member testimonial authoring UI - #1494

Merged
ardalis merged 1 commit into
mainfrom
issue-1490-testimonials-member-authoring
Nov 17, 2026
Merged

ardalis merged 1 commit into
mainfrom
issue-1490-testimonials-member-authoring

Conversation

@ardalis

@ardalis ardalis commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1490
Relates to #1472

Summary

Members can now write and manage their own testimonials at My Profile → Testimonials (/User/MyProfile/Testimonials).

Testimonials module

  • ITestimonialAuthoring (Contracts) is the member-facing set of use cases: list, get, create a draft, update, submit, and delete a draft. Every call is scoped by memberId. Another member's testimonial is reported as not found.
  • TestimonialOperationResult returns Success, NotFound, NotAllowed, or Invalid with field errors. It is a small local type, so Contracts stays dependency-free.
  • TestimonialLimits: field max lengths now live in Contracts so the web forms can validate up front. The domain constants point at them.
  • TestimonialAuthoring validates input into field-level errors, then calls the domain. It maps illegal state transitions and concurrency conflicts to NotAllowed. The clock comes from TimeProvider.
  • MemberTestimonialDto exposes CanEdit, CanSubmit, and CanDelete, plus reviewer feedback. Feedback is shown for ChangesRequested and Declined.

Web

  • Testimonials/Index lists the member's testimonials with a status badge, an explanation, and reviewer feedback. It has Edit/View, Submit for review, and Delete draft (drafts only, with a confirmation) actions.
  • Testimonials/Edit/{id?} creates or edits: the text, plus display name (prefilled from the member's name), title, organization, and an optional https photo URL that falls back to the avatar. It has Save draft and Save and submit for review buttons.
    • The page is read-only while the testimonial is Pending review, Accepted, or Declined. A crafted POST in those states returns 409 and changes nothing.
  • My Profile has a new "Testimonials" card.

Test infrastructure

  • Added AuthenticatedWebApplicationFactory and TestAuthHandler. The handler is a header-based scheme, so functional tests can sign in as a seeded member.
  • Fixed CustomWebApplicationFactory. It built a new EF internal service provider inside the AddDbContext options callback, which runs once per scope. Every request scope therefore saw an empty in-memory app/identity database, and the seed data was effectively invisible. Each provider is now built once, the same way the testimonials registration already did it.
  • The module grants InternalsVisibleTo to the functional tests, so they can apply admin review transitions until the admin queue (Testimonials: admin review queue #1491) exists.

Tests

  • Module (DevBetterWeb.Modules.Testimonials.Tests/Application/TestimonialAuthoringTests) covers:
    • create, invalid input (field errors, including non-https and javascript: photo URLs), and over-long fields
    • edit when editable; edit, submit, and delete blocked once submitted
    • the status check running before validation
    • submit clearing feedback, and delete for drafts only
    • other members' testimonials → NotFound on every operation
    • list scoping and order, feedback and permission flags, and DI resolution
  • Functional (DevBetterWeb.FunctionalTests/RazorPages/Testimonials/MyTestimonialsPages) covers:
    • anonymous users are challenged (401)
    • the list shows only the member's own testimonials, and the display name defaults to the member's name
    • create, edit, and the invalid-input redisplay
    • submit from the list, and save-and-submit from the edit page
    • editing blocked after submit: read-only render, 409 on POST, and an error shown for blocked submit/delete
    • the ChangesRequested flow: feedback shown, then edit and resubmit
    • Accepted is read-only
    • another member gets a 404 on view, edit, submit, and delete

Verification

  • dotnet build: 0 errors.
  • dotnet test: all suites pass (Modules.Testimonials 101, Tests 118, UnitTests 195, AppHost 4, Functional 19).
  • dotnet format --verify-no-changes --include <touched files>: clean. The repo-wide format failures were already on main and are not touched here.
  • A separate agent reviewed the change independently and found no blockers or significant findings. The minor findings were addressed: the back link, extra functional coverage, a11y labels on per-card actions, and author-line formatting. The remaining ones are recorded with reasons in .claude/plans/2026-11-16-issue-1490-testimonials-member-authoring.md.

Deploy notes

  • No schema changes and no new migration.

🤖 Generated with Claude Code

Members can write, edit, submit, and delete draft testimonials at
/User/MyProfile/Testimonials. Each testimonial shows its status and any
reviewer feedback, and becomes read-only once submitted.

- Testimonials module: public ITestimonialAuthoring use cases scoped by
  memberId, a dependency-free TestimonialOperationResult, shared
  TestimonialLimits, and field-level input validation.
- Web: Index and Edit Razor pages plus a My Profile card.
- Tests: module service tests, and authenticated functional tests that
  use a header-based test auth scheme.
- Fix CustomWebApplicationFactory so the in-memory app and identity DBs
  persist across scopes, making seed data visible to requests.

Fixes #1490
Relates to #1472

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert.True(match.Success, $"No antiforgery token found on {formPageUrl}.");

var form = new Dictionary<string, string>(fields) { ["__RequestVerificationToken"] = match.Groups[1].Value };
return await client.PostAsync(postUrl, new FormUrlEncodedContent(form));
}

/// <param name="Field">The <see cref="TestimonialDraftInput"/> property name, or null for a general error.</param>
public sealed record TestimonialValidationError(string? Field, string Message);
@ardalis
ardalis merged commit dfcbd70 into main Nov 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testimonials: member authoring UI

2 participants